﻿<!-- Ammouri Gauge Control -->
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Ammouri.UI.Controls">

    <!-- Type converters-->
    <local:RadiusToDiameterConverter x:Key="radiusToDiameterConverter"/>
    <local:BackgroundColorConverter x:Key="backgroundColorConverter" />
    <local:SizeConverter x:Key="sizeConverter" />
    <local:ImageOffsetConverter x:Key="imageOffsetConverter" />
    <local:ColorToSolidColorBrushConverter x:Key="colorToSolidColorBrushConverter" />
    <local:RangeIndicatorLightPositionConverter x:Key="rangeIndicatorLightPositionConverter"/>
    <local:PointerCenterConverter x:Key="pointerCenterConverter"/>
    <local:GlassEffectWidthConverter x:Key="glassEffectWidthConverter" />
    <local:GenericSolidColorConverter x:Key="genericSolidColorConverter" />

    <Style TargetType="local:CircularGaugeControl" >
        <Setter Property="ResetPointerOnStartUp" Value="True" />
        <Setter Property="ScaleValuePrecision" Value="5" />
        <Setter Property="RangeIndicatorThickness" Value="5"/>
        <Setter Property="GaugeBackgroundColor" Value="red" />
        <Setter Property="BelowOptimalRangeColor" Value="Yellow" />
        <Setter Property="OptimalRangeColor" Value="Green" />
        <Setter Property="AboveOptimalRangeColor" Value="Red" />
        <Setter Property="DialTextColor" Value="White" />
        <Setter Property="DialTextFontSize" Value="8" />
        <Setter Property="BorderColor" Value="#11000000" />

        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="local:CircularGaugeControl">
                    <!-- Root Grid-->
                    <Grid x:Name="LayoutRoot" 
                          Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                          Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" >

                        <!-- Border -->
                        <Ellipse x:Name="OuterFrame" 
                                 StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness}"
                                 Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                                 Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Radius, Converter={StaticResource radiusToDiameterConverter}}" 
                                 Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=GaugeBackgroundColor, Converter={StaticResource backgroundColorConverter}}"
                                 Stroke="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderColor, Converter={StaticResource genericSolidColorConverter}}">
                        </Ellipse>


                        <!-- Gauge Image -->
                        <Image Source="{TemplateBinding ImageSource}" 
                               Width="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageSize, Converter={StaticResource sizeConverter}, ConverterParameter=Width }" 
                               
                               Height="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageSize, Converter={StaticResource sizeConverter}, ConverterParameter=Height }"
                               
                               RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=ImageOffset, Converter={StaticResource imageOffsetConverter}}">

                        </Image>

                        <!-- Meter Name -->
                        <TextBlock Text="{TemplateBinding MeterName}" FontFamily="/Assets/DS-DIGI_0.TTF#DS-Digital"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"  
                                   Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextColor, Converter={StaticResource colorToSolidColorBrushConverter}}"
                                   FontSize="{TemplateBinding DialTextFontSize}"
                                                         
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=MeterNameOffset, Converter={StaticResource rangeIndicatorLightPositionConverter}}">
                        </TextBlock>

                        <!-- Dial Text -->
                        <TextBlock Text="{TemplateBinding DialText}" FontFamily="/Assets/DS-DIGI_0.TTF#DS-Digital"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"  
                                   Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextColor, Converter={StaticResource colorToSolidColorBrushConverter}}"
                                   FontSize="{TemplateBinding DialTextFontSize}"
                                                         
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextOffset, Converter={StaticResource rangeIndicatorLightPositionConverter}}">
                        </TextBlock>

                        <!-- Numeric Indecator Text -->
                        <TextBlock Text="{TemplateBinding NumericValue}" FontFamily="Ammouri.UI.Controls/Assets/DS-DIGI_0.TTF#DS-Digital"
                                   HorizontalAlignment="Center" VerticalAlignment="Center"  
                                   Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=DialTextColor, Converter={StaticResource colorToSolidColorBrushConverter}}"
                                   FontSize="{TemplateBinding DialTextFontSize}"
                                                         
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=NumericTextOffset, Converter={StaticResource rangeIndicatorLightPositionConverter}}">
                        </TextBlock>

                        <!-- Pointer -->
                        <Path x:Name="Pointer" Stroke="#FFE91C1C" StrokeThickness="2" 
                              Width="{TemplateBinding PointerLength}" 
                              Height="{TemplateBinding PointerThickness}" HorizontalAlignment="Center"
                              Data="M1,1 L1,10 L156,6 z" Stretch="Fill"  RenderTransformOrigin="0,0.5" 
                              RenderTransform="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                            Path=PointerLength, Converter={StaticResource pointerCenterConverter}}">                            
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF890A0A" Offset="0.197"/>
                                    <GradientStop Color="#FFC40808" Offset="1"/>
                                    <GradientStop Color="#FFE32323" Offset="0.61"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                            <Path.Effect>
                                <DropShadowEffect BlurRadius="10" Opacity="0.5" ShadowDepth="5"  Direction="316"/>
                            </Path.Effect>
                        </Path>


                        <!--Pointer Cap-->
                        <Ellipse x:Name="PointerCap" Height="{TemplateBinding PointerCapRadius}" Width="{TemplateBinding PointerCapRadius}" StrokeThickness="4" Opacity="1" >
                            <Ellipse.Stroke>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF000000" Offset="0.675"/>
                                    <GradientStop Color="#FFC1B5B5" Offset="0.031"/>
                                </LinearGradientBrush>
                            </Ellipse.Stroke>
                            <Ellipse.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF152029" Offset="0.846"/>
                                    <GradientStop Color="#FF140204" Offset="0.342"/>
                                </LinearGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>